package com.woniu.hander;

import com.alibaba.fastjson.JSON;
import com.woniu.util.ResData;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class LoginoutHandler implements LogoutSuccessHandler {
    @Override
    public void onLogoutSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException {
        httpServletResponse.setContentType("application/json;charset=UTF-8");

        PrintWriter writer = httpServletResponse.getWriter();

        writer.print(JSON.toJSONString(ResData.LOGINOUT));
        writer.flush();
        writer.close();
    }
}
